@extends('admin.layout.layout', ['row' => @$page])

@section('contain')
    <style>
        .warranty-image-wrapper{
            display: flex;
            flex-wrap: wrap;
        }
        .warranty-image-wrapper .warranty-image-list{
            display: flex;
            flex-wrap: wrap;
        }
        .warranty-image-wrapper .warranty-image-list .item{
            width: 100px;
            flex: 0 0 100px;
            height: 100px;
            padding: 0;
            overflow: hidden;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            display: block;
            position: relative;
        }
        .warranty-image-wrapper .warranty-image-list .item{
            margin: 10px;
        }
        .warranty-image-wrapper .warranty-image-list .item img{
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .warranty-image-wrapper .warranty-image-list .item .x-close {
            font-size: 16px;
            position: absolute;
            top: 4px;
            right: 4px;
            z-index: 99;
            font-weight: lighter;
            text-shadow: none;
            display: block;
            cursor: pointer;
        }
        .warranty-image-wrapper .warranty-image-list .item .x-close:hover{
            color: #f00;
        }
        .warranty-image-wrapper .add, .qrcode-image-wrapper .qrcode-list{
            width: 100px;
            flex: 0 0 100px;
            height: 100px;
            padding: 0;
            overflow: hidden;
            box-sizing: border-box;
            display: flex;
            flex-wrap: nowrap;
            justify-content: center;
            align-items: center;
            border: 1px solid #eee;
            cursor: pointer;
            position: relative;
            margin: 10px;
        }

        .warranty-image-wrapper .add .open{
            font-size: 64px;
            line-height: 1em;
            color: #666;
        }
        .warranty-image-wrapper .add .store-upload-image, .store-upload-detail-image, .qrcode_image, .store-upload-picture-image{
            display: block;
            position: absolute;
            opacity: 0;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            cursor: pointer;
            width: 100%;
            height: 100%;
            z-index: 29;
        }
        .detail-image-area, .picture-image-area {
            width: 100px;
            flex: 0 0 100px;
            height: 100px;
            padding: 0;
            overflow: hidden;
            box-sizing: border-box;
            display: flex;
            flex-wrap: nowrap;
            justify-content: center;
            align-items: center;
            border: 1px solid #eee;
            cursor: pointer;
            position: relative;
            margin: 10px;
        }
        .detail-image-area .item img, .qrcode-list img, .picture-image-wrapper .item img{
            width: 100%;
            height: 100%;
        }
        .detail-image-area .item .x-close, .qrcode-image-wrapper .item .x-close, .picture-image-wrapper .item .x-close {
            font-size: 16px;
            position: absolute;
            top: 4px;
            right: 4px;
            z-index: 99;
            font-weight: lighter;
            text-shadow: none;
            display: block;
            cursor: pointer;
        }
        .detail-image-area .item .x-close:hover, .picture-image-wrapper .item .x-close:hover{
            color: #f00;
        }
    </style>

    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions">
            </div>
        </div>
        <table class="table s3">
            <tbody>

            <tr>
                <td colspan="6" class="tst">{{ ts('baseinformation') }}</td>
            </tr>
            <tr>
                <td class="tth">经销商账号</td>
                <td class="ttd">{{ $data->unique_id}}</td>
                <td class="tth">店面名称</td>
                <td class="ttd">{{ $data->abbr}}</td>
                <td class="tth">公司名称</td>
                <td class="ttd">{{ $data->company_name  }}</td>
            </tr>
            <tr>
                <td class="tth">联系人</td>
                <td class="ttd">{{ $data->first_name }}</td>
                <td class="tth">联系方式</td>
                <td class="ttd">{{ $data->cell_phone ?: $data->phone_number }}</td>
                <td class="tth">状态</td>
                <td class="ttd">{{ $data->status == 1 ? '启用' : '停用'  }}</td>
            </tr>
            </tbody>
        </table>
        <form action="/{{ request()->path() }}/../" enctype="multipart/form-data" method="post" class="dealer-form" id="create_form">
            @csrf
            <h3 class="section_sub_title">门店信息</h3>

            <div class="form-item form-s1">
                <div class="form-label" required="">授权级别</div>
                <div class="form-input">
                    {{ ts('mdtype'.$data->mdtype) }}
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">授权日期</div>
                <div class="form-input">
                    <div class="input-group mb-3 custom-control-inline flatpickr-date-range">
                        <div class="input-group-prepend">
                            <span class="input-group-text">{{ @$label ?: ts('date') }}</span>
                        </div>
                        <input type="text" name="startdate" placeholder="{{ ts('SESECTDATE') }}" class="startdate flatpickr form-control" value="{{ $data->start_date ?? '' }}">
                        <div class="input-group-prepend">
                            <span class="input-group-text">{{ ts('TO') }}</span>
                        </div>
                        <input type="text" name="enddate" placeholder="{{ ts('SESECTDATE') }}" class="enddate flatpickr form-control" value="{{ $data->end_date ?? '' }}">
                    </div>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">授权编号</div>
                <div class="form-input">
                    <input type="text" name="store_code" value="{{ $data->store_code ?? old('store_code') }}" class="form-control" required>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">营业时间</div>
                <div class="input-group mb-3 custom-control-inline flatpickr-date-range" style="max-width: 500px;">
                    <input type="text" name="start_time" placeholder="开始时间" id="start_time" class="start_time flatpickr form-control" value="{{ $data->open_time }}">
                    <div class="input-group-prepend">
                        <span class="input-group-text">{{ ts('TO') }}</span>
                    </div>
                    <input type="text" name="end_time" placeholder="结束时间" id="end_time" class="end_time flatpickr form-control" value="{{$data->close_time }}">
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">门店特色</div>
                <div class="form-input" id="detail-special-area">
                    @if (!empty($features) && $features->isNotEmpty())
                        @foreach ($features as  $key => $feature)
                        <div class="detail-image-wrapper">
                            <div class="detail-list">
                                <div class="detail-image-area" style="float: left;">
                                    <input type="file" name="file" class="store-upload-detail-image" style="float: left;" accept="image/*">
                                    <div class="item">
                                        <input type="text" hidden value="{{ $feature->picture_url }}" name="features_images[]">
                                        <img src="{{ getInstallPicture($feature->picture_url) }}">
                                        <i class="fa fa-trash-o x-close"></i>
                                    </div>
                                </div>
                                <div style="float: left;margin-top: 20px;">
                                    <input type="text" name="detail_desc[]" value="{{ $feature->detail }}" class="detail_desc"  />
                                </div>
                            </div>
                            @if ($key == 0)
                            <div style="margin-left: 300px;padding-top: 20px;">
                                <input type="button" class="btn-default btn-primary" id="add_desc" style="width: 100px; height: 30px;" value="添加" />
                            </div>
                            @else
                                <div style="margin-left: 300px;padding-top: 20px;">
                                    <input type="button" class="btn-default btn-primary deal_desc" style="width: 100px; height: 30px;" value="删除" />
                                </div>
                            @endif
                            <br clear="all" />
                        </div>
                        @endforeach
                    @else
                        <div class="detail-image-wrapper">
                            <div class="detail-list">
                                <div class="detail-image-area" style="float: left;">
                                    <input type="file" name="file" class="store-upload-detail-image" style="float: left;" accept="image/*">
                                </div>
                                <div style="float: left;margin-top: 20px;">
                                    <input type="text" name="detail_desc[]" value="" class="detail_desc"  />
                                </div>
                            </div>
                            <div style="margin-left: 300px;padding-top: 20px;">
                                <input type="button" class="btn-default btn-primary" id="add_desc" style="width: 100px; height: 30px;" value="添加" />
                            </div>
                            <br clear="all" />
                        </div>
                    @endif
                </div>
            </div>

            <div class="form-item form-s1" style="height: 400px;">
                <div class="form-label" required="">店面介绍</div>
                <div class="form-input">
                    <div id="store_detail" name="store_detail" class="text" style="width:800px; height:200px;"></div>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">
                    <div>所获荣誉</div>
                </div>
                <div class="form-input">
                    <textarea name="honor"></textarea>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">
                    <div>二维码图片上传</div>
                </div>
                <div class="form-input">
                    <div class="qrcode-image-wrapper" id="qrcode_picture">
                        <div class="qrcode-list">
                            <input type="file" name="file" class="qrcode_image" accept="image/*">
                            <div class="item">
                                <input type="text" hidden value="{{ $data->qrcode_url ?: '/upload/202105/rytAnkDjiXpNEQWbH0tIEvF4JICoxC.png' }}" name="qrcode_images[]">
                                <img src="{{ getInstallPicture($data->qrcode_url ?: '/upload/202105/rytAnkDjiXpNEQWbH0tIEvF4JICoxC.png') }}">
                                <i class="fa fa-trash-o x-close"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">
                    <div>展示照片</div>
                </div>
                <div class="form-input" id="picture-special-area">
                    @if (!empty($pictures) && $pictures->isNotEmpty())
                        @foreach ($pictures as  $key => $picture)
                            <div class="picture-image-wrapper">
                                <div class="picture-list">
                                    <div class="picture-image-area" style="float: left;">
                                        <input type="file" name="file" class="store-upload-picture-image" style="float: left;" accept="image/*">
                                        <div class="item">
                                            <input type="text" hidden value="{{ $picture->picture_url }}" name="picture_images[]">
                                            <img src="{{ getInstallPicture($picture->picture_url) }}">
                                            <i class="fa fa-trash-o x-close"></i>
                                        </div>
                                    </div>
                                    <div style="float: left;margin-top: 20px;">
                                        <input type="text" name="picture_desc[]" value="{{ $picture->detail }}" class="picture_desc"  />
                                    </div>
                                </div>
                                @if ($key == 0)
                                    <div style="margin-left: 300px;padding-top: 20px;">
                                        <input type="button" class="btn-default btn-primary" id="add_picture" style="width: 100px; height: 30px;" value="添加" />
                                    </div>
                                @else
                                    <div style="margin-left: 300px;padding-top: 20px;">
                                        <input type="button" class="btn-default btn-primary deal_picture" style="width: 100px; height: 30px;" value="删除" />
                                    </div>
                                @endif
                                <br clear="all" />
                            </div>
                        @endforeach
                    @else
                        <div class="picture-image-wrapper">
                            <div class="picture-list">
                                <div class="picture-image-area" style="float: left;">
                                    <input type="file" name="file" class="store-upload-picture-image" style="float: left;" accept="image/*">
                                </div>
                                <div style="float: left;margin-top: 20px;">
                                    <input type="text" name="picture_desc[]" value="" class="picture_desc"  />
                                </div>
                            </div>
                            <div style="margin-left: 300px;padding-top: 20px;">
                                <input type="button" class="btn-default btn-primary" id="add_picture" style="width: 100px; height: 30px;" value="添加" />
                            </div>
                            <br clear="all" />
                        </div>
                    @endif
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">视频</div>
                <div class="form-input">
                    <input type="text" name="video_url" id="video_url" class="video_url form-control" value="{{ $data->video_url ?? '' }}" placeholder="视频链接" />
                    <input class="upload" type="file" name="video_file" id="video_file" onchange=onUpload2(this.files[0])>
                    <div class="preview preview2"></div>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">增加认证人员(空格|;分割)</div>
                <div class="form-input" style="width: 30px;">
                    <textarea name="persons" style="height: 100px; width: 200px;">{{ $data->persons }}</textarea>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">是否推荐</div>
                <div class="form-input" style="width: 30px;">
                    <select name="is_advanced" class="form-control" style="width: 60px;">
                        <option value="1" {{ $data->is_advanced == 1 ? 'selected' : '' }}>是</option>
                        <option value="2" {{ $data->is_advanced == 2 ? 'selected' : '' }}>否</option>
                    </select>
                </div>
            </div>

            <div class="form-item form-s1">
                <div class="form-label" required="">前端是否显示</div>
                <div class="form-input" style="width: 30px;">
                    <select name="front_show" class="form-control" style="width: 60px;">
                        <option value="1" {{ $data->front_show == 1 ? 'selected' : '' }}>是</option>
                        <option value="2" {{ $data->front_show == 2 ? 'selected' : '' }}>否</option>
                    </select>
                </div>
            </div>

            <div class="mt-4">
                <button class="btn btn-primary" id="submit">{{ ts('submit') }}</button>
            </div>

            <input type="hidden" value="{{ $id }}" name="id" />
        </form>

    </div>

    <template id="StorageImageItem">
        <div class="item">
            <input type="text" hidden value="" name="storage_images[]">
            <img src="{{ getInstallPicture(@$v->image_src) }}">
            <i class="fa fa-trash-o x-close"></i>
        </div>
    </template>
    <template id="FeaturesImageItem">
        <div class="item">
            <input type="text" hidden value="" name="features_images[]">
            <img src="{{ getInstallPicture(@$v->image_src) }}">
            <i class="fa fa-trash-o x-close"></i>
        </div>
    </template>
    <template id="QrCodeImageItem">
        <div class="item">
            <input type="text" hidden value="" name="qrcode_images[]">
            <img src="{{ getInstallPicture(@$v->image_src) }}">
            <i class="fa fa-trash-o x-close"></i>
        </div>
    </template>
    <template id="PictureCodeImageItem">
        <div class="item">
            <input type="text" hidden value="" name="picture_images[]">
            <img src="{{ getInstallPicture(@$v->image_src) }}">
            <i class="fa fa-trash-o x-close"></i>
        </div>
    </template>
@endsection


@section('script')
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>
    <script>
        const E = window.wangEditor
        const editor = new E('#store_detail')
        const $text1 = $('#store_detail')
        editor.config.onchange = function (html) {
            // 第二步，监控变化，同步更新到 textarea
            $text1.val(html)
        }
        editor.config.uploadFileName = 'file'
        editor.config.uploadImgServer = '/admin/store/uploadImage'
        editor.create()
        editor.txt.html('<?php echo !empty($data->detail) ? $data->detail : '' ?>')

        $(function () {
            $("#start_time").flatpickr({
                enableTime: true,
                noCalendar: true,
                dateFormat: "H:i",
                time_24hr: true,
                minTime: "00:00",
                maxTime: "12:00",
                defaultDate: "{{ $data->open_time }}"
            });
            $("#end_time").flatpickr({
                enableTime: true,
                noCalendar: true,
                dateFormat: "H:i",
                time_24hr: true,
                minTime: "12:00",
                maxTime: "23:00",
                defaultDate: "{{ $data->close_time }}"
            });
            $(".province_json, .city_json, .creator_id").select2();
            $(".add_system").on('click', function () {
                let html = '<tr><td><input type="text" name="system_user[]" class="form-control" value="" /></td><td>';
                html += '<select class="form-control" name="system_name[]"><option value="">请选择</option> <option value="iphone">iphone</option><option value="ipad">ipad</option></select></td><td><input type="text" name="system_phone[]" class="form-control" value="" /></td>';
                html += '<td><button type="button" class="btn btn-danger btn-sm delete_system">删除</button></td></tr>';
                $(".system-table").append(html);
            });

            $("#dist").select2();
            $("#dealer").select2();
            $("#dist").on("change", function () {
                let dist_id = $(this).val();
                if (dist_id == 0 || dist_id == '') {
                    return;
                }
                $.ajax({
                    url: '/admin/ajax/getUsers',
                    dataType: 'json',
                    data: {
                        user_id: dist_id,
                        t: 'd',
                    },
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        $("#dealer").empty();
                        if (typeof data.data != 'undefined') {
                            let html = '';
                            let list = data.data;
                            for (let i in list) {
                                html += '<option value="'+ list[i]['value'] +'">' + list[i]['label'] +'</option>';
                            }
                            $("#dealer").append(html);
                        }
                    }
                })
            });

            $("#add_desc").on("click", function() {
                let html = '<div class="detail-image-wrapper"><div class="detail-list"><div class="detail-image-area" style="float: left;"><input type="file" name="file" class="store-upload-detail-image" style="float: left;" accept="image/*">';
                html += '</div><div style="float: left;margin-top: 20px;"><input type="text" name="detail_desc[]" class="detail_desc"  /></div>';
                html += '</div><div style="margin-left: 300px;padding-top: 20px;"><input type="button" class="btn-default btn-primary deal_desc" style="width: 100px; height: 30px;" value="删除" /></div><br clear="all" /></div>';
                $("#detail-special-area").append(html);
            });

            $("#add_picture").on("click", function() {
                let html = '<div class="picture-image-wrapper"><div class="picture-list"><div class="picture-image-area" style="float: left;"><input type="file" name="file" class="store-upload-picture-image" style="float: left;" accept="image/*">';
                html += '</div><div style="float: left;margin-top: 20px;"><input type="text" name="picture_desc[]" class="picture_desc"  /></div>';
                html += '</div><div style="margin-left: 300px;padding-top: 20px;"><input type="button" class="btn-default btn-primary deal_picture" style="width: 100px; height: 30px;" value="删除" /></div><br clear="all" /></div>';
                $("#picture-special-area").append(html);
            });

            $("#submit").on("click", function () {
                if (checkForm()) {
                    var form = formObjV2('form.dealer-form');
                    let content = editor.txt.html();
                    form.content = content;
                    console.log(form);
                    $.ajax({
                        url: '/admin/store/update',
                        data: form,
                        dataType: 'json',
                        type: 'post',
                        success: function (data) {
                            if (data.code != 0) {
                                toastr.error(data.msg)
                                return false;
                            }

                            swal('', '编辑成功！', 'success')
                                .then(function (d) {
                                    window.location.assign('/admin/store');
                                })
                        }
                    });
                }
                return false;
            });
        });

        function storeWIU(data) {
            var html = $('#StorageImageItem').html()
            var item = $(html)
            item.find('input').val(data.url)
            item.find('img').attr('src', data.host + data.url)
            return item;
        }

        function storeQrcode(data) {
            var html = $('#QrCodeImageItem').html()
            var item = $(html)
            item.find('input').val(data.url)
            item.find('img').attr('src', data.host + data.url)
            return item;
        }
        function storeFeatures(data) {
            var html = $('#FeaturesImageItem').html()
            var item = $(html)
            item.find('input').val(data.url)
            item.find('img').attr('src', data.host + data.url)
            return item;
        }
        function storePictures(data) {
            var html = $('#PictureCodeImageItem').html()
            var item = $(html)
            item.find('input').val(data.url)
            item.find('img').attr('src', data.host + data.url)
            return item;
        }

        $("body").on("click", '.deal_desc', function () {
            var that = $(this);
            that.parents('.detail-image-wrapper').remove();
        });
        $("body").on("click", '.deal_picture', function () {
            var that = $(this);
            that.parents('.picture-image-wrapper').remove();
        });
        $('body').on('click', '.qrcode-list .x-close', function() {
            var that = $(this)
            $(this).parents('.item').remove();
        })
        $('body').on('click', '.detail-list .x-close', function() {
            var that = $(this)
            $(this).parents('.item').remove();
        })

        $('body').on('click', '.picture-list .x-close', function() {
            var that = $(this)
            $(this).parents('.item').remove();
        })


        $('body').on('change', '.store-upload-detail-image', function() {
            var that = $(this)
            var files = $(this)[0].files
            for (var i = 0; i <= files.length - 1; i++) {
                var formData = new FormData()
                formData.append('file', files[i])
                request.post('/admin/ajax/upload_file', formData)
                    .then( function(d) {
                        var data = d.data;
                        console.log(data);
                        that.parents('.detail-image-area').append(storeFeatures(data));
                        if (typeof viewer == 'undefined') {
                            viewer = new Viewer(document.getElementById('store_picture'), {
                                show: function (){
                                    viewer.update();
                                },
                            });
                        }
                        viewer.update();
                    })
                    .catch(function(e){
                        sweetAlert('', e.msg || 'error', 'error')
                        console.log(e);
                    })
            }
            that.val('')
        });

        $('body').on('change', '.store-upload-picture-image', function() {
            var that = $(this)
            var files = $(this)[0].files
            for (var i = 0; i <= files.length - 1; i++) {
                var formData = new FormData()
                formData.append('file', files[i])
                request.post('/admin/ajax/upload_file', formData)
                    .then( function(d) {
                        var data = d.data;
                        console.log(data);
                        that.parents('.picture-image-area').append(storePictures(data));
                        if (typeof viewer == 'undefined') {
                            viewer = new Viewer(document.getElementById('picture-special-area'), {
                                show: function (){
                                    viewer.update();
                                },
                            });
                        }
                        viewer.update();
                    })
                    .catch(function(e){
                        sweetAlert('', e.msg || 'error', 'error')
                        console.log(e);
                    })
            }
            that.val('')
        });

        $('body').on('change', '.qrcode_image', function() {
            var that = $(this)
            var files = $(this)[0].files
            for (var i = 0; i <= files.length - 1; i++) {
                var formData = new FormData()
                formData.append('file', files[i])
                request.post('/admin/ajax/upload_file', formData)
                    .then( function(d) {
                        var data = d.data;
                        console.log(data);
                        that.parents('.qrcode-list').append(storeQrcode(data))
                    })
                    .catch(function(e){
                        sweetAlert('', e.msg || 'error', 'error')
                        console.log(e);
                    })
            }
            that.val('')
        })

        $('body').on('change', '.store-upload-image', function() {
            var that = $(this)
            var files = $(this)[0].files
            for (var i = 0; i <= files.length - 1; i++) {
                var formData = new FormData()
                formData.append('file', files[i])
                request.post('/admin/ajax/upload_file', formData)
                    .then( function(d) {
                        var data = d.data;
                        console.log(data);
                        that.parents('.warranty-image-wrapper').find('.warranty-image-list').append(storeWIU(data))
                        if (typeof viewer == 'undefined') {
                            viewer = new Viewer(document.getElementById('store_picture'), {
                                show: function (){
                                    viewer.update();
                                },
                            });
                        }
                        viewer.update();
                    })
                    .catch(function(e){
                        sweetAlert('', e.msg || 'error', 'error')
                        console.log(e);
                    })
            }
            that.val('')
        })
        $('body').on('click', '.warranty-image-wrapper .x-close', function() {
            var that = $(this)
            $(this).parents('.item').remove();
        })

        function onUpload2 (file) {
            var blob = new Blob([file]), // 文件转化成二进制文件
                url = URL.createObjectURL(blob); //转化成url
            if (/image/g.test(file.type)) {
                var img = $('<img src="' + url + '">');
                img[0].onload = function(e) {
                    URL.revokeObjectURL(this.src);  // 释放createObjectURL创建的对象
                }
                $('.preview2').html('').append(img);
            } else if (/video/g.test(file.type)) {
                var video = $('<video controls src="' + url + '">');
                $('.preview2').html('').append(video);
                video[0].onload = function(e) {
                    URL.revokeObjectURL(this.src);  // 释放createObjectURL创建的对象
                }
                let formData = new FormData();
                formData.append('file', file)
                $.ajax({
                    url: '/admin/store/uploadVideo',
                    data: formData,
                    type: 'post',
                    contentType: false,
                    processData: false,  // 增加这一行，不处理参数
                    success: function (data) {
                        if (data.code != 0) {
                            toastr.error(data.msg)
                            return false;
                        }
                        swal('', '上传成功', 'success')
                        $("#video_url").val(data.data)
                    }
                });
            }
        }

        function checkForm() {
            var form = formObjV2('form.dealer-form');
            var msg = '';
            console.log(form);
            let content = editor.txt.html();
            if (!content) {
                msg = '缺少门店特色';
            }
            if (!form.persons) {
                msg = '缺少认证人员';
            }
            if (!form.features_images || form.features_images.length < 1) {
                msg = '门店特色缺少图片';
            }
            if (!form.detail_desc || form.detail_desc.length < 1) {
                msg = '门店特色缺少描述';
            }
            if (!form.picture_images || form.picture_images.length < 1) {
                msg = '缺少图片';
            }
            if (!form.picture_desc || form.picture_desc.length < 1) {
                msg = '图片缺少描述';
            }
            if (!form.startdate) {
                msg = '缺少授权开始日期';
            }
            if (!form.enddate) {
                msg = '缺少授权开始日期';
            }
            if (!form.start_time) {
                msg = '缺少开始时间';
            }
            if (!form.end_time) {
                msg = '缺少结束时间';
            }

            if (!form.storage_images || form.storage_images.length < 1) {
                msg = '所属荣誉不能少于一张';
            }

            if (msg) {
                alert(msg);
                return false;
            }

            return true;
        }
    </script>
@endsection
